package com.ayoka.mvp;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.CourseAssignmentBean;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;
import com.jcp.baselibrary.utils.UIUtils;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface CourseAssignmentDescriptionMVP {

    interface CourseAssignmentDescriptionModel {
    }

    interface ICourseAssignmentDescriptionView extends IBaseView {

        void configCourseAssignmentDetailData(CourseAssignmentBean data);
    }

    class CourseAssignmentDescriptionPresenter extends BasePresenter<ICourseAssignmentDescriptionView> {

        public void getCourseAssignmentDetailData(int courseAssignmentId, int courseId) {
            mViewRef.get().showWaitDialog(UIUtils.getString(R.string.loading));
            API.getCourseAssignmentDetailData(this, courseAssignmentId, courseId, new OkHttpListener<BaseResponse<CourseAssignmentBean>>() {
                @Override
                public void onSuccess(BaseResponse<CourseAssignmentBean> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().configCourseAssignmentDetailData(response.data);
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                }
            });
        }
    }

}
